#include<bits/stdc++.h>
#define int long long
using namespace std;
const int Maxn = 1000010;
int n, Q, ans;
string s;
signed main(){
	ios::sync_with_stdio(false);
	freopen("good.in", "r", stdin);
	freopen("good.out", "w", stdout);
	cin >> n >> Q;
	cin >> s;
	s = ' ' + s;
	while(Q--){
		int l, r;
		cin >> l >> r;
		string t;
		int tot = 0, sum = 0, cnt = 0;
		for(int i = l ; i <= r ; i++){
			if(s[i] == '1'){
				sum++;
				t[++tot] = s[i];
				continue;
			}
			if(sum){
				sum--;
				t[++tot] = s[i];
				continue;
			}
			cnt++;
			t[++tot] = '1';
			t[++tot] = s[i];
		}
		// cout << cnt << " ";
		sum = 0;
		for(int i = tot ; i >= 1 ; i--){
			if(t[i] == '1'){
				sum++;
				continue;
			}
			if(sum){
				sum--;
				continue;
			}
			cnt++;
		}
		ans ^= cnt;
		// cout << cnt << '\n';
		// for(int i = 1 ; i <= tot ; i++) cout << t[i];
		// cout << '\n';
	}
	cout << ans << '\n';
	return 0;
}
/*
10 5
0001001111
1 6
1 10
5 7
4 7
4 6

*/